import autowaf

def generic_ui(bld):
	source = 'bundles/generic-ui.lv2/'
	bld.install_files('${LV2DIR}/generic-ui.lv2', source+'*.ttl')
	bld.install_files('${PREFIX}/include', 'headers/*.h')
	
	bld.install_as('${LV2DIR}/generic-ui.lv2/generic-ui.h', 'headers/lv2_generic_ui.h')
	
def generic_gtk(bld):
	dir = 'bundles/generic-gtk.lv2/'
	bundle = 'generic-gtk.lv2'
	name = 'lv2gtk'
	
	src = '''
		bundles/generic-gtk.lv2/source/plugin.cpp
		bundles/generic-gtk.lv2/source/main-widget.cpp
		bundles/generic-gtk.lv2/source/generic-gtk.cpp
	'''
	
	obj = bld.new_task_gen('cxx', 'shlib')
	obj.export_incdirs = ['.' 'bundles/generic-ui.lv2']
	obj.source 	     = src
	obj.includes     = ['.' 'bundles/generic-ui.lv2']
	obj.uselib       = 'PAQ LV2GUI'
	obj.name         = 'generic-gtk'
	obj.target       = name
	obj.install_path = None
	
	bld.add_group() #this is needed so waf doesn't try to move a file that doesn't exist
	
	library = 'lib' + name + '.so'
	renamed = name + '.so'
	
	bld.new_task_gen(
		name = 'Rename',
		after = 'plugin',
		source = library,
		target = renamed,
		rule = 'cp -f ${SRC} ${TGT}',
		install_path = '${LV2DIR}/' + bundle
	)
	
	bld.install_files('${LV2DIR}/generic-gtk.lv2', dir+'*.ttl')
	bld.install_files('${LV2DIR}/generic-gtk.lv2/pixmaps', dir+'pixmaps/*')
	